<?php
	
	
	$cCategory = new CCategory;
	$cType = new CType;


	$arrCategory = $cCategory -> CCategoryList();
	
	$notification ="";
	
	if(isset($_GET['notification']))
	{
		$notification =constant($_GET['notification']);
	}
	
	
		
	if(is_array($arrCategory))
	{
		$mainContent = '<div id="content2">
		
		
						<span style="font-size:10px;color:#FF0000;font-weight:bold;font-family:Arial, Helvetica, sans-serif">'.$notification.'</span>
						
						
						
						<table border="0" width="98%" style="position:relative;border-collapse:collapse;" align = "center">';
		foreach ($arrCategory as $keyCategory => $valueCategory)
		{
			
			$arrType = $cType ->CTypeListOfCategory($valueCategory['id']);
			
			$tableOfType = "";	
			if(is_array($arrType))
			{
				$tableOfType .= '<table border="0" width="100%" style="position:relative; border-collapse:collapse;" align = "center">';
				foreach ($arrType as $keyType => $valueType)
				{
					$tableOfType .='<tr>
										<td>
											'.$valueType['name'].'
										</td>
										
										<td align="right">
											<span>
												<a href="main.php?jmp=types&to=idbedi&idbpos='.$valueType['id'].'"><img src="images/edit.png" width="16px" height="16px" border="0" title="Edit this type"></a>
												
												<a href="main.php?jmp=types&to=idbdel&idbpos='.$valueType['id'].'"><img src="images/delete.png" width="16px" height="16px" border="0" title="Delete this type"></a>
											</span>
										</td>
									</tr>
					';
				}
				
				$tableOfType .= '</table>';
			}
			
			
			
			$mainContent .='<tr bgcolor="#CCCCCC">';
			
				$mainContent .='<td>
				
								'.$valueCategory['name'].'
				
								</td>
								<td align="right">
									<span>
										<a href="main.php?jmp=categories&to=idbedi&idbpos='.$valueCategory['id'].'"><img src="images/edit.png" width="16px" height="16px" border="0" title="Edit this categy"></a>										
										<a href="main.php?jmp=categories&to=idbdel&idbpos='.$valueCategory['id'].'"><img src="images/delete.png" width="16px" height="16px" border="0" title="Delete this category"></a>
									</span>
								</td>
								';
			
			
			$mainContent .='</tr>
							
							<tr>
								<td colspan="2">
									'.$tableOfType.'
								</td>
							</tr>';

		}
		
		
		
		
		$mainContent .='</table></div>';

		//print_r($arrCategory);
	}	
	else
	{
		$mainContent ="Updating data....";
	}
            
			
?>